<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 烽
  Date: 2015/7/15
  Time: 22:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>${title}</title>
    <meta charset="utf-8">
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.css">


    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://apps.bdimg.com/libs/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>
<body>
<div id="all" class="col-md-12">


    <jsp:include page="/WEB-INF/views/common/head.jsp"/>

    <jsp:include page="/WEB-INF/views/common/menu.jsp"/>

    <div id="content" class="col-md-10 col-md-offset-1">
        <div class="row">
            <div id="type" class="col-md-2">
                <ul class="list-unstyled">
                    <li><a href="<%=request.getContextPath()%>/blog/allBlog">所有</a></li>
                    <hr>
                    <c:forEach items="${articleTypeList}" var="type">
                        <li><a href="<%=request.getContextPath()%>/blog/allBlog?type=${type.id}">${type.name}</a></li>
                        <li>&nbsp;</li>
                    </c:forEach>
                    <hr>
                    <li><a href="#top">返回顶部</a></li>
                </ul>
            </div>
            <div id="list" class="col-md-10">
                <c:if test="${allPageCount != 0}">
                    <table class="table table-striped">
                        <c:forEach items="${articles}" var="a">
                            <tr>
                                <td>
                                    <h2>
                                        <a href="<%=request.getContextPath()%>/blog/blog?id=${a.id}&type=${type}">${a.title}</a>
                                    </h2>

                                    <p>分类：${a.typeName}&nbsp;&nbsp;&nbsp;${a.formatTime}</p>
                                </td>
                            </tr>
                        </c:forEach>
                    </table>
                </c:if>
                <c:if test="${allPageCount == 0}">
                    <p class="text-center">
                        当前类别暂无文章！
                    </p>
                </c:if>

            </div>
        </div>
        <c:if test="${allPageCount != 0}">
            <div id="paging" align="center">
                <nav>
                    <ul class="pagination pagination-lg">
                        <%--上一页标记--%>
                        <li
                            <c:if test="${hasPervious !=true}">
                                class="disabled"
                            </c:if>
                            >
                            <c:if test="${hasPervious ==true}">
                                <a href="<%=request.getContextPath()%>/blog/allBlog?pageNum=${pageNum-1}&type=${type}"
                                   aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </c:if>
                            <c:if test="${hasPervious !=true}">
                                <a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
                            </c:if>

                        </li>
                        <%--页码标记    --%>
                        <c:forEach var="i" begin="${allPageCount - 5 >=1 ? allPageCount - 5:1}" end="${allPageCount}"
                                   step="1">
                            <li
                                    <c:if test="${i == pageNum}">
                                        class="active"
                                    </c:if>
                                    >
                                <a href="<%=request.getContextPath()%>/blog/allBlog?pageNum=${i}&type=${type}">${i}</a>
                            </li>
                        </c:forEach>
                        <%--下一页标记    --%>
                        <li
                            <c:if test="${hasNext !=true}">
                                class="disabled"
                            </c:if>
                            >
                            <c:if test="${hasNext ==true}">
                                <a href="<%=request.getContextPath()%>/blog/allBlog?pageNum=${pageNum+1}&type=${type}"
                                   aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </c:if>
                            <c:if test="${hasNext !=true}">
                                <a href="#" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
                            </c:if>

                        </li>
                    </ul>
                </nav>
            </div>
        </c:if>

    </div>

    <jsp:include page="/WEB-INF/views/common/foot.jsp"/>
</div>
</body>
</html>

